#!/bin/bash

echo "========================================="
echo "智能排课系统 - 部署验证脚本"
echo "========================================="
echo ""

# 服务器IP
SERVER_IP="172.16.29.198"

echo "【1】检查 Nginx 状态..."
ssh root@$SERVER_IP "systemctl status nginx | grep Active"
echo ""

echo "【2】检查 Nginx 配置..."
ssh root@$SERVER_IP "cat /etc/nginx/conf.d/paike.conf"
echo ""

echo "【3】检查后端服务..."
ssh root@$SERVER_IP "ps aux | grep java | grep -v grep"
echo ""

echo "【4】测试后端直接访问（8090端口）..."
curl -X POST "http://$SERVER_IP:8090/admin/login" \
  -H "Content-Type: application/json" \
  -d '{"adminNo":"admin","password":"123456"}'
echo ""
echo ""

echo "【5】测试前端页面访问（80端口）..."
curl -I "http://$SERVER_IP/"
echo ""

echo "【6】测试 Nginx 代理的API（80端口，/api前缀）..."
curl -X POST "http://$SERVER_IP/api/admin/login" \
  -H "Content-Type: application/json" \
  -d '{"adminNo":"admin","password":"123456"}'
echo ""
echo ""

echo "========================================="
echo "验证完成"
echo "========================================="
echo ""
echo "【重要】"
echo "- 前端应该访问: http://$SERVER_IP (80端口)"
echo "- 不要直接访问: http://$SERVER_IP:8090 (这样会带/api前缀)"
echo "========================================="








